class Student(object):
    # 类属性
    name = 'Student'

    def __init__(self, name):
        self.name = name


s = Student('apple')
# 打印类属性
print(Student.name)
# 打印实例属性
print(s.name)
# 删除实例属性
del s.name
print(s.name)

# 练习
'''
为了统计老师人数,
可以给Student类增加一个类属性，
每创建一个实例，该属性自动增加：
'''


class Teacher(object):
    count = 0

    def __init__(self, name):
        Teacher.count += 1
        self.name = name


# 测试:
if Teacher.count != 0:
    print('测试失败!')
else:
    bart = Teacher('Bart')
    if Teacher.count != 1:
        print('测试失败!')
    else:
        lisa = Teacher('Bart')
        if Teacher.count != 2:
            print('测试失败!')
        else:
            print('Students:', Teacher.count)
            print('测试通过!')